package leetcode20211002;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LUYAO
 * Date: 2021-10-02
 * Time: 10:51
 */
public class two_dimensionArrayFind {
    public static void main(String[] args) {

    }
}

class Solution1 {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        int i = matrix.length-1;
        int j = 0;
        while(i >= 0 && j < matrix[0].length){
            if(matrix[i][j] > target){
                i--;
            }else if(matrix[i][j] < target){
                j++;
            }else {
                return true;
            }
        }

        return false;
    }
}
